using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DAO;
using DTO;

namespace Presentation
{
    public partial class UserControlToa : UserControl
    {
        public UserControlToa()
        {
            InitializeComponent();
        }

        private void UserControlToa_Load(object sender, EventArgs e)
        {

        }

        private void btnTracuu_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime tngay = DateTime.Parse(dtpTungay.Text);
                DateTime dngay = DateTime.Parse(dtpDenngay.Text);
                HinhThucBanDao htbDao = new HinhThucBanDao();
                HinhThucBanDto[] htbDto = htbDao.SelectHinhThucBan(tngay, dngay, (int)MyConnection.Hinhthucban.Toa);

                dgvToa.AutoGenerateColumns = false;
                dgvToa.DataSource = htbDto;
            }
            catch (Exception exp)
            {

                throw new Exception(exp.ToString());
            }
        }

        private void dgvToa_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            DataGridView grv = (DataGridView) sender;
            Utils.MakeSothutuColumn(grv, "itemStt"); ;
        }

        private void btnLuuBaoCao_Click(object sender, EventArgs e)
        {
            Utils.ExportToExcel(dgvToa);
        }
    }
}
